
function sum_units(){
    form = document.getElementById('subjects_assess');
    var cbResults=0;
    for (var i = 0; i < form.elements.length; i++ ) {
        if (form.elements[i].type == 'checkbox' && form.elements[i].className=='subjects') {
        
            if (form.elements[i].checked == true) {
                cbResults = +cbResults + +form.elements[i].value;
                form.elements[i + +1].disabled = false;
            }else{
                form.elements[i + +1].disabled = true;
            }
        }
    }
   
     document.getElementById("result_page").innerHTML = cbResults;     
    document.getElementById("result_hidden").value=cbResults;         //sum of units
    
    var tuition = document.getElementById('tuition').value;          //value of tuition per unit
    
    var ako = document.getElementById('tuition_fee').innerHTML= (+cbResults * +tuition)
    var ako = document.getElementById('tuition_fee').value= +cbResults * +tuition;
    document.getElementById('tuition_fee_form').value = (+cbResults * +tuition).toFixed(2);
    get_assess();
}

function agreement_status(kalagayan){
    //this is used in the admission for the agreement segment
   if(kalagayan==false){
       window.document.getElementById('agreement').disabled= true;
   }else{
       window.document.getElementById('agreement').disabled=false;
   }
}

function auto_check_off(){
    if((window.document.getElementById('note').checked)==false){
        alert('mao');
    }
}

function validate_date(testDate){
    var date_regex = /^(0[1-9]|1[0-2])\-(0[1-9]|1\d|2\d|3[01])\-(19|20)\d{2}$/ ;
    if(!(date_regex.test(testDate)))
    {
        alert('Please follow the correct format for date');
        window.document.getElementById('check_date').focus();
        
    }
}

function download_print_receipt(){ 
    window.print();
}

function delete_row(id){
     //  var myTD=document.getElementById(id);
      //myTD.remove();    
       get_assess();
}

function get_assess(){      
   form = document.getElementById('subjects_assess');
       var cbResults=0;
    for (var i = 0; i < form.elements.length; i++ ) {
        if (form.elements[i].className == 'assessment' && form.elements[i].type == 'checkbox'){
            if(form.elements[i].checked == true) {
                cbResults = +cbResults + +form.elements[i].value;
                 form.elements[i + +1].disabled = false; 
            }else{
                  form.elements[i + +1].disabled = true; 
            }
        }
    }   
    document.getElementById("result_assess").innerHTML = cbResults.toFixed(2);
    document.getElementById("result_hidden_assess").value=cbResults;    
}

                                    
function createTarget(t){
window.open("",t, "width=864,height=1104,left=10,top=1000");
return true;
}

function account_assess(){ 
   //change_tuition();    
   form = document.getElementById('accounting_assess');
       var cbResults=0;
    for (var i = 0; i < form.elements.length; i++ ) {
        if (form.elements[i].className == 'assessment' && form.elements[i].type == 'checkbox'){
            if(form.elements[i].checked == true) {
                cbResults = +cbResults + +form.elements[i].value;
                 form.elements[i + +1].disabled = false; 
            }else{
                  form.elements[i + +1].disabled = true; 
            }
        }
    }   
    document.getElementById("result_assess").innerHTML = cbResults.toFixed(2);
    document.getElementById("result_hidden_assess").value=cbResults;    
}

function change_tuition(){
    mytarget = document.getElementById("tuition_fee_form").value;
      document.getElementById('tuition_fee').value= mytarget;
     document.getElementById('tuition_fee').innerHTML= mytarget;
     account_assess();
}


function confirmGetMessage() {
    alert('me');
  //display a confirmation box asking the visitor if they want to get a message
  var theAnswer = confirm("Get a message?");
    
  //if the user presses the "OK" button display the message "Javascript is cool!!"
  if (theAnswer){
     alert("Javascript is cool.");
  }
    
 //otherwise display another message
 else{
    alert("Here is a message anyway.");
  }
}

function repage_cog(){
    window.document.getElementById('mahahali1').remove();
    window.document.getElementById('mahahali2').remove();
    window.print();
}

function repage_enrollment() {
     window.document.getElementById('laen_ipakita').style.removeProperty('display');   
     window.document.getElementById('mahahali').style.setProperty('display','none');
     window.print();
}

function itago_muna(){
   window.document.getElementById('laen_ipakita').style.setProperty('display','none');
}

function check_num(value){
    if(isNaN(value)){
        alert('You have entered a non-numeric character');
    }   
}

function palitan_action(aksyon){
    if(aksyon!='add'){
        window.document.getElementById('palitan').value=aksyon;
        window.document.getElementById('palitan').innerHTML=aksyon;
    }
}

function cashier_print(){
    window.document.getElementById("mawawara_title").remove();
      window.document.getElementById('mawawara_button').style.setProperty('display','none');
    window.document.getElementById("mawawara_total").remove();
    window.document.getElementById('invisible').style.setProperty('display','none');
     window.document.getElementById('amo_total').style.removeProperty('display'); 
      window.document.getElementById('amo_words').style.removeProperty('display'); 
      window.print();
   
}

function remove_other_dept(klass){
     form = window.document.getElementById("department");
    for (var i = 0; i < form.rows.length; i++ ) {
        if (form.rows[i].className!=klass && form.rows[i].className!="") {  
            form.rows[i].style.setProperty('display','none');
        }else{
             form.rows[i].style.removeProperty('display');
        }
    }
}
